package com.lin.linchatgpt.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;

import java.io.Serializable;
import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 实体类。
 *
 * @author 15898
 * @since 2023-06-22
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "chat_message")
public class Message implements Serializable {

    /**
     * 聊天历史记录id
     */
    @Id(keyType = KeyType.Generator, value = "myUUID")
    private String id;

    /**
     * 聊天主题id
     */
    private String subjectId;

    /**
     * 消息父级id
     */
    private String parentMessageId;

    /**
     * 聊天角色
     */
    private String role;

    /**
     * 聊天内容
     */
    private String content;

    /**
     * 消息创建时间，纳秒级
     */
    private Long recordTime;

    /**
     * 逻辑删除
     */
    @Column(isLogicDelete = true)
    @JsonIgnore
    private Integer isDelete;

    /**
     * 创建时间
     */
    @Column(onInsertValue = "now()")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @Column(onUpdateValue = "now()", onInsertValue = "now()")
    private LocalDateTime modifyTime;

    /**
     * 排序
     */
    private Long sequence;

}
